package com.sheng.project.test;

/**
 * @author liusheng
 * @date 2022/08/30
 */
public class CodeUtil {

    private static final CodeUtil instance = new CodeUtil();
    private static long temp = System.currentTimeMillis();
    private static int num = 0;

    private CodeUtil() {
    }

    public static CodeUtil getInstance() {
        return instance;
    }

    public String getCode() {
        long currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis > temp) {
            temp = currentTimeMillis;
            num = 0;
        }
        return temp + "DD" + String.format("%0" + 2 + "d", num++);
    }
}
